#include "stdafx.h"


#define WINDOW_WIDTH  320
#define WINDOW_HEIGHT 320

#define ARRAY_SIZE_IN_ELEMENTS(a) (sizeof(a)/sizeof(a[0]))

enum VB_TYPES {
	INDEX_BUFFER,
	POS_VB,
	NORMAL_VB,
	TEXCOORD_VB,
	BONE_VB,
	NUM_VBs            
};
GLuint m_VAO;
GLuint m_Buffers[NUM_VBs];
int init()					 
{
	// Create the VAO
	glGenVertexArrays(1, &m_VAO);   
	glBindVertexArray(m_VAO);

	// Create the buffers for the vertices attributes
	glGenBuffers(ARRAY_SIZE_IN_ELEMENTS(m_Buffers), m_Buffers);
	return true;
}



void processSpecialKeys(int key, int x, int y)
{
	 
}
void processPassiveMouseButtons(int xx, int yy)
{
}
void processMouseButtons(int button, int state, int xx, int yy) 
{
	
}

void processKeys(unsigned char key, int xx, int yy) 
{
	
}

void processMouseMotion(int xx, int yy)
{
}
void mouseWheel(int wheel, int direction, int x, int y)
{
}
void changeSize(int width, int height) 
{
	
}
void renderScene(void) 
{
	
	// Clear the color buffer
	glClear ( GL_COLOR_BUFFER_BIT );
	GLfloat vertices[] = {1,0,0, 0,1,0, -1,0,0};
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, vertices);
	glDrawArrays(GL_TRIANGLES, 0, 3);
	glDisableClientState(GL_VERTEX_ARRAY);

	glutSwapBuffers();

}
void shutDown ()
{

	// Delete program object
}
int main(int argc, char **argv)
{
	//test();
	//  GLUT initialization
	glutInit(&argc, argv);

	glutInitDisplayMode(GLUT_DEPTH|GLUT_DOUBLE|GLUT_RGBA|GLUT_MULTISAMPLE);

	glutInitContextVersion (2, 0);
	glutInitContextFlags (GLUT_COMPATIBILITY_PROFILE );

	glutInitWindowPosition(100,100);
	glutInitWindowSize(WINDOW_WIDTH,WINDOW_HEIGHT);
	glutCreateWindow("Hello Textrue!");


	//  Callback Registration
	glutDisplayFunc(renderScene);
	glutReshapeFunc(changeSize);
	glutIdleFunc(renderScene);

	glutSpecialFunc(processSpecialKeys);
	glutPassiveMotionFunc(processPassiveMouseButtons);

	//	Mouse and Keyboard Callbacks
	glutKeyboardFunc(processKeys);
	glutMouseFunc(processMouseButtons);
	glutMotionFunc(processMouseMotion);

	glutMouseWheelFunc ( mouseWheel ) ;

	//	Init GLEW
	//glewExperimental = GL_TRUE;
	glewInit();
	if (glewIsSupported("GL_VERSION_2_0"))
		printf("Ready for OpenGL 2.0\n");
	else {
		printf("OpenGL 2.0 not supported\n");
		exit(1);
	}

	//  Init the app (load model and textures) and OpenGL
	if (!init())
		printf("Could not Load the Model\n");

	printf ("Vendor: %s\n", glGetString (GL_VENDOR));
	printf ("Renderer: %s\n", glGetString (GL_RENDERER));
	printf ("Version: %s\n", glGetString (GL_VERSION));
	printf ("GLSL: %s\n", glGetString (GL_SHADING_LANGUAGE_VERSION));


	// return from main loop
	glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

	//  GLUT main loop
	glutMainLoop();
	shutDown();
}

